package com.znsd.zl.house.controller;

import com.znsd.zl.house.entity.HistoryEntity;
import com.znsd.zl.house.service.IHistoryService;
import com.znsd.zl.utils.BaseController;
import com.znsd.zl.utils.R;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @ClassName HistoryController
 * @Description 描述
 * @author zhubin
 * @Version v1.0
 */
@RestController
@RequestMapping("/zl/history")
public class HistoryController extends BaseController<IHistoryService, HistoryEntity,Integer> {

	@GetMapping("/findIp")
	public R findById(String ip){
		List<HistoryEntity> historys = this.service.findByIp(ip);
		return R.ok().put("page",historys);
	}

	@Override
	@PostMapping
	public R save(@RequestBody HistoryEntity historyEntity) {
		List<HistoryEntity> historys = service.findByHistory(historyEntity.getQueryHistory());
		if (historys.size() == 0 ) {
			service.save(historyEntity);
		}
		return R.ok();
	}
}
